import { getProductTypes, productTypesEnum } from '@/enums/product'

export const productBaseCols = Array.of(
  { key: 'ProductId', label: '产品ID' },  //  暂时显示出来
  // { key: 'ProductType', label: '产品类型', tag: true },
  // { key: 'ProductTypeTxt', label: '产品类型', tag: true},
  { key: 'ProductType', label: '产品类型', tag: true, filter: getProductTypes },
  { key: 'ProductName', label: '产品名' },
  { key: 'quantity', label: '数量', isDefaultShowDynamicColumn: false },
  { key: 'Code', label: '编码', tag: true },
  { key: 'CategoricalId', label: '产品分类ID', isDefaultShowDynamicColumn: false },
  { key: 'CategoricalName', label: '产品分类' },
  { key: 'ProductShopType', label: '输出类型ID', tag: true, isDefaultShowDynamicColumn: false },
  { key: 'ProductShopTypeName', label: '输出类型', tag: true },
  { key: 'ProductSize', label: '产品尺寸' },
  { key: 'Describe', label: '产品描述', isDefaultShowDynamicColumn: false },
  { key: 'SizeDetailId', label: '标准尺寸' },
  { key: 'CreateBy', label: '创建人', isDefaultShowDynamicColumn: false },
  { key: 'CreateTime', label: '创建时间', isDefaultShowDynamicColumn: false },
  { key: 'LastModifyBy', label: '修改人', isDefaultShowDynamicColumn: false },
  { key: 'LastModifyTime', label: '修改时间', isDefaultShowDynamicColumn: false },
  { key: 'Status', label: '状态', isDefaultShowDynamicColumn: false, tag: true },
  { key: 'ProductPrintTypeId', label: '打印类型', isDefaultShowDynamicColumn: false, tag: true },
  { key: 'CutFilePath', label: '切割文件', isDefaultShowDynamicColumn: false },
  { key: 'Weight', label: '标准重量', isDefaultShowDynamicColumn: false },
  { key: 'SingleWeight', label: '单P重量', isDefaultShowDynamicColumn: false }
)

/**
 *  =[{originProps:'',newProps:''}]
 //  {[originProps]:[newProps]}
 *  工具函数
 * @param arrObj
 * @param props
 * @returns {*}
 */
const transferObj = (arrObj, props = { key: 'dataIndex', label: 'title' }) =>
  arrObj.reduce((acc, cur) =>
      [...acc, Object.keys(props).reduce((o, k) =>
        ({ ...o, [props[k]]: cur[k] }), {})]
    , Array.of())

const UPDATE_DETAIL = 'UPDATE_DETAIL'
const CREATE_DETAIL = 'CREATE_DETAIL'
const VIEW_DETAIL = 'VIEW_DETAIL'

export { UPDATE_DETAIL, CREATE_DETAIL, VIEW_DETAIL }

//  默认产品类型为
export const createProductFactory = ({ ProductType = 1, ProductShopType = 1 } = {}) => {
  return {
    // ProductId: '',
    Name: '',
    Code: '',
    CategoricalId: '',
    ProductType,
    ProductShopType,  //  默认为
    ProductSize: '',
    Describe: '',
    CreateBy: '',
    CreateTime: '',
    LastModifyBy: '',
    LastModifyTime: '',
    SizeDetailId: '',
    Status: '',
    ProductPrintTypeId: '',
    CutFilePath: '',
    Weight: '',
    SingleWeight: ''
  }
}
